package com.atguigu.gmall.mq.receiver;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 监听延迟对象的消息
 */
@Component
public class DelayReceiver {

    //用queue前提是设置好绑定关系
    @RabbitListener(queues = DelayedMqConfig.queue_delay_1)
    public void get(String message){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("Receive queue_delay_1: " + simpleDateFormat.format(new Date()) + " Delay rece." + message);
    }
}
